import requests
import logging

# 设置日志
logger = logging.getLogger(__name__)
logger.setLevel(level = logging.INFO)
handler = logging.FileHandler("E:/log.txt")
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

accept = 'application/json, text/javascript, */*; q=0.01'
accept_encoding = 'gzip, deflate'
accept_language = 'zh-CN,en-US;q=0.8'
user_agent = '''Mozilla/5.0 (Linux; Android 7.0; M5 Note Build/NRD90M; wv) \
AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 \
MQQBrowser/6.2 TBS/043808 Mobile Safari/537.36 \
MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN'''
host = 'wx.10086.cn'
connection = 'keep-alive'
cookies = '''koa.sid=hoCW0TfNFOTryNq7rQPrS25jJmCUyx7i; \
gr_user_id=08506005-93d4-4ea8-8655-5061ee39b5e5; \
8a2e2725efabd35c_gr_session_id_4558a7a9-1cba-44bb-b79e-d6fd13103d7f=true; \
8a2e2725efabd35c_gr_session_id=4558a7a9-1cba-44bb-b79e-d6fd13103d7f; \
8a2e2725efabd35c_gr_last_sent_sid_with_cs1=4558a7a9-1cba-44bb-b79e-d6fd13103d7f; \
8a2e2725efabd35c_gr_last_sent_cs1=oJAS9uBBV92YV1cspfUOdJL3CYwE; \
8a2e2725efabd35c_gr_cs1=oJAS9uBBV92YV1cspfUOdJL3CYwE; \
ADHOC_MEMBERSHIP_CLIENT_ID1.0=8789f3e5-8faf-da4b-75c1-9afca0ad82f9'''
x_auth_token = "609f78ee-166a-4022-af20-2b10cc187612"
headers = {'Accept': accept, 'Accept-Language': accept_language, 'User-Agent': user_agent,
           'Host': host, 'Connection': connection, 'x-auth-token': x_auth_token}

# 签到任务一
url ="http://wx.10086.cn/shXi/global/sxxa_signin/activity/updateTaskState"
data={'taskId':1}
r = requests.get(url, headers=headers, data=data)
logger.info(r.text)

# 签到任务二
data={'taskId':2}
r = requests.get(url, headers=headers, data=data)
logger.info(r.text)

url = "http://wx.10086.cn/shXi/global/sxxa_signin/activity/queryCurrentCoinCount"
r = requests.get(url, headers=headers)
logger.info(r.text)